﻿
//取万
function towan(num) {
    var result=  num > 0 ? (num / 10000).toFixed(2)  : num;
    return result;
}
// 字符串千分位
function toThousands(num) {
    var num = (num || 0).toString(), result = '';
    while (num.length > 3) {
        result = ',' + num.slice(-3) + result;
        num = num.slice(0, num.length - 3);
    }
    if (num) { result = num + result; }
    return result;
}
// 字符串千分位
function toThousands2(num) {
    return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
}
//获取传值参数
function Request(strName) {
    var strHref =window.document.location.href;
    var intPos = strHref.indexOf("?");
    var strRight = strHref.substr(intPos + 1);
    var arrTmp = strRight.split("&");
    for (var i = 0; i < arrTmp.length; i++) {
        var arrTemp = arrTmp[i].split("=");
        if (arrTemp[0].toUpperCase() == strName.toUpperCase())
            return arrTemp[1];
    }
    return "";
}
//获取url参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
}
function tokm(o) {
    //公里标格式化 k1000+001
    var rvalue = '&nbsp;';
    try {
        if (o && o != '') {
            var point = o.toString().indexOf('.');
            if (point > 0) {
                var o1 = o.toString().substring(0, point); //小数点前数字
                var o2 = (parseFloat('0.' + o.toString().substring(point + 1)) * 1000).toString().substring(0, 6).toString(); //小数点后数字
                if (o2.length < 3) { for (var i = 0; i <= (3 - o2.length) ; i++) { o2 = '0' + o2; } }
                point = o2.toString().indexOf('.');
                var o5 = o2;
                if (point > 0) {
                    var o3 = o2.toString().substring(0, point); //
                    var o4 = o2.toString().substring(point); //
                    if (o3.length < 3) { for (var i = 0; i <= (3 - o3.length) ; i++) { o3 = '0' + o3; } }
                    o5 = o3 + o4;
                } else {
                }
                rvalue = 'K' + o1 + '+' + o5;
            }
            else {
                rvalue = 'K' + o.toString();
            }
        } else { }
        if (o == 0 && o.toString() != '') {
            rvalue = 'K' + o.toString();
        }
    } catch (e) { }
    return rvalue;
}
function getKM(o) {
    var r = 0;
    if (o && o != "" && o.replace('K', 'k').indexOf('k') >= 0) {
        o = o.substring(1);
    }

    if (o.indexOf('+') >= 0) {
        r = parseFloat(o.substring(0, o.indexOf('+')) + '.' + o.substring(o.lastIndexOf('+') + 1).replace('.', ''), 8 + o.length - 1);
    }
    else {
        r = parseFloat(o, 8 + o.length);
    }
    return r;
}
function kmline() {
    //公里标中间的-
    return ' <span style="color:#999999">-</span> ';
}
//填数字的文本框，失去焦点判断是否填了数字
function NaNPointOut(obj) {
    if (isNaN($(obj).val()) && $(obj).val() != "") {
        layer.msg("不支持非数字类型的文本！");
        $(obj).val("").focus();
    }
}
function mathround(o, len) {
    //浮点数四舍五入 精度
    var rvalue = '&nbsp;';
    var num = 0;
    var _len = '1';
    if (!isNaN(len)) {
        for (var i = 0; i < len; i++) {
            _len += '0';
        }
        _len = parseInt(_len);
    } else { _len = 100000; }
    try {
        return Math.round(parseFloat(o) * _len) / _len;
    } catch (e) { }
    return rvalue;
}
///字符截取
String.format = function () {
    if (arguments.length == 0)
        return null;
    var str = arguments[0];
    for (var i = 1; i < arguments.length; i++) {
        var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
        str = str.replace(re, arguments[i]);
    }
    return str;
};
function stringCut(string, end) {
    var rvalue = '&nbsp;';
    try {
        if (string.length < end) {
            return string;
        } else {
            rvalue = string.substring(0, end) + "...";
        }
    } catch (e) { return rvalue; }
    return rvalue;
}
Date.prototype.format = function (format) {
    var o = {
        "M+": this.getMonth() + 1, //month   
        "d+": this.getDate(),    //day  
        "h+": this.getHours(),   //hour   
        "m+": this.getMinutes(), //minute   
        "s+": this.getSeconds(), //second   
        "q+": Math.floor((this.getMonth() + 3) / 3), //quarter  
        "S": this.getMilliseconds() //millisecond 
    }
    if (/(y+)/.test(format))
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
    return format;
}
//获取年月日时分秒
function getNowFormatDate2() {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();
    return currentdate;
}
function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
    return currentdate;
}
function setAddTime(jsondate, format) {
    var format = typeof (format) == 'string' ? format : 'yyyy-MM-dd hh:mm:ss.S';
    try {
        if (jsondate != null) {
            var rvalue = eval("new " + jsondate.substr(1, jsondate.length - 2)).format(format);
            return rvalue || '&nbsp;';
        } else { return '&nbsp;'; }
    }
    catch (e) {
        return '&nbsp;';
    }
}
//js方法返回值：2015-03-19
 function formatDate(date) {
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    m = m < 10 ? '0' + m : m;
    var d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    return y + '-' + m + '-' + d;
 };
 //js方法返回值：2015-03-1912:00
 function formatDateTime(date) {
     var y = date.getFullYear();
     var m = date.getMonth() + 1;
     m = m < 10 ? ('0' + m) : m;
     var d = date.getDate();
     d = d < 10 ? ('0' + d) : d;
     var h = date.getHours();
     var minute = date.getMinutes();
     minute = minute < 10 ? ('0' + minute) : minute;
     return y + '-' + m + '-' + d + ' ' + h + ':' + minute;
 };
function stopBubble(e) {
    // 如果传入了事件对象，那么就是非ie浏览器  
    if (e && e.stopPropagation) {
        //因此它支持W3C的stopPropagation()方法  
        e.stopPropagation();
    } else {
        //否则我们使用ie的方法来取消事件冒泡  
        window.event.cancelBubble = true;
    }
}
/*对象序列化为字符串*/
String.toSerialize = function (obj) {
    var ransferCharForJavascript = function (s) {
        var newStr = s.replace(
        /[\x26\x27\x3C\x3E\x0D\x0A\x22\x2C\x5C\x00]/g,
        function (c) {
            ascii = c.charCodeAt(0)
            return '\\u00' + (ascii < 16 ? '0' + ascii.toString(16) : ascii.toString(16))
        }
        );
        return newStr;
    }
    if (obj == null) {
        return null
    }
    else if (obj.constructor == Array) {
        var builder = [];
        builder.push("[");
        for (var index in obj) {
            if (typeof obj[index] == "function") continue;
            if (index > 0) builder.push(",");
            builder.push(String.toSerialize(obj[index]));
        }
        builder.push("]");
        return builder.join("");
    }
    else if (obj.constructor == Object) {
        var builder = [];
        builder.push("{");
        var index = 0;
        for (var key in obj) {
            if (typeof obj[key] == "function") continue;
            if (index > 0) builder.push(",");
            builder.push(String.format("\"{0}\":{1}", key, String.toSerialize(obj[key])));
            index++;
        }
        builder.push("}");
        return builder.join("");
    }
    else if (obj.constructor == Boolean) {
        return obj.toString();
    }
    else if (obj.constructor == Number) {
        return obj.toString();
    }
    else if (obj.constructor == String) {
        return String.format('"{0}"', ransferCharForJavascript(obj));
    }
    else if (obj.constructor == Date) {
        return String.format('{"__DataType":"Date","__thisue":{0}}', obj.getTime() - (new Date(1970, 0, 1, 0, 0, 0)).getTime());
    }
    else if (this.toString != undefined) {
        return String.toSerialize(obj);
    }
}
//*******************************tab类*******************************
function createtab(name, url, target, isiframe, isfull) {
     
    if (url && url != '') {
        $("#divbody").html('');
        if (isfull == 'true') {
            $('#divbody-theme').hide();
            $('#divbody-title').hide();
        } else {
            $('#divbody-theme').show();
            $('#divbody-title').show();
        }
        if (isiframe == 'true') {
            $("#divbody").html('<div class="loadingdiv">&nbsp;&nbsp;&nbsp;&nbsp;</div>');
            var iframe = $("<iframe name=\"tabframe\" src=\"" + url + "\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"hidden\" style='overflow:hidden'></iframe>");
            iframe.height($("#divbody-content").height());
            $("#divbody").html(iframe);
        }
        else {
            if (target == '_blank') {
                window.open(url, "fullscreen=1");
            } else {
                $('#page-title-menu').html(name);
                $('#page-title').html(name);
                $("#divbody").html('<div class="loadingdiv">&nbsp;&nbsp;&nbsp;&nbsp;</div>');
                if (url != '###') {
                    var a = $("#divbody");
                    a.load(url + '?' + Math.random(), function (responseText, textStatus, XMLHttpRequest) {
                    });
                }
            }
        }
    }
}
//*******************************窗口类*******************************
function createwin(options) {
    var id = options.id ? options.id : Math.random();
    var url = options.url ? options.url : '';
    var str = '<div class="modal formmodal modal-full" id="modal' + id + '" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="flase" data-backdrop="static">';
    str += '<div class="modal-dialog">';
    str += '<div class="modal-content">';
    str += '<div class="modal-header">';
    //str += '<button class="close" aria-hidden="true" type="button" data-dismiss="modal"></button>';
    str += '<button type="button" class="close" onclick="closewin(\'' + options.id + '\')"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>';
    str += '<h4 class="modal-title">' + (options.title ? options.title : '') + '</h4>';
    str += '</div>';
    str += '<div class="modal-body" style="overflow:auto"><div class="loadingdiv">&nbsp;&nbsp;&nbsp;&nbsp;</div> ';
    str += '</div>';
    str += '<div class="modal-footer"> ';
    str += '</div>';
    str += '</div>';
    str += '</div>';
    str += '</div>';
    $(document.body).append(str);
    $('#modal' + id).modal('show');
    if (options.fullscreen === true) {
        $('#modal' + id + ' .modal-dialog').width('99%');
        $('#modal' + id + ' .modal-body').height($(window).height() - 150);
    } else {
        if (options.width) { $('#modal' + id + ' .modal-dialog').width(options.width); }
        if (options.height) { $('#modal' + id + ' .modal-body').height(options.height); }
    }
    if (url != '') {
        if (options.isiframe === true) {
            $('#modal' + id + ' .modal-body').css('padding', '0px');
            var iframe = $("<iframe name=\"winframe\" src=\"" + url + "\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"hidden\" style='overflow:hidden'></iframe>");
            $('#modal' + id + ' .modal-body').html(iframe);
            $('#modal' + id + ' .modal-footer').hide();
        }
        else {
            $('#modal' + id + ' .modal-body').load(url.indexOf('?') > 0 ? (url + '&r=' + Math.random()) : (url + '?r=' + Math.random()), function (data) {
                var modalfoot = $('#modal' + id + ' .modal-foot');
                $('#modal' + id + ' .modal-footer').html(modalfoot.html());
                modalfoot.hide();
            });
        }
    }
}
//id为空关闭所有
function closewin(id) {
    if (id) {
        $('#modal' + id).modal('hide');
        $('#modal' + id).remove();

    } else {
        $('.formmodal').modal('hide');
        $('.formmodal').remove();
    }
}
function toastrOptions() {
    toastr.options = {
        "closeButton": true,
        "debug": false,
        "positionClass": "toast-top-center",
        "onclick": null,
        "timeOut": "2000"
    }
}
//*******************************消息类*******************************
function messageSuccess(title, msg) {
    toastrOptions();
    toastr['success'](msg, title);
}
function messageInfo(title, msg) {
    toastrOptions();
    toastr['info'](msg, title);
}
function messageWarning(title, msg) {
    toastrOptions();
    toastr['warning'](msg, title);
}
function messageError(title, msg) {
    toastrOptions();
    toastr['error'](msg, title);
}
function messageConfirm(title) {
    bootbox.confirm(title, function (result) {
        alert("Confirm result: " + result);
    });
}
function operate(rvalue, refresh, winid) {
    if (rvalue) {
        top.messageSuccess("提示", "操作成功");
        if (refresh) {
            if (typeof (eval('item_select')) == "function") {
                top.item_select();
            }
        }
    } else {
        top.messageError('错误', '非常抱歉，操作失败，请稍后重试');
    }
    setTimeout(function () { top.closewin(winid); }, 1000);

}
//*******************************同类操作类*******************************
function addactions(o) {
    var dropdownmenu = $('#dropdown-menu');
    var strs = [];
    for (var i = 0; i < o.length; i++) {
        strs.push('<li url="' + o[i].url + '" ' + (o[i].target ? ('target="' + o[i].target + '"') : '') + ' comname="' + o[i].title + '"><a href="###">' + o[i].title + '</a></li>');
        if (o[i].split === true) {
            strs.push('<li class="divider"></li>');
        }
    }
    dropdownmenu.html(strs.join(''));
    if (o.length > 0) { $('#btn-group').show(); } else { $('#btn-group').hide(); }
}
//*******************************操作类*******************************
//删除
function operate_delete(o) {
    var action = { Action: "get", act: 'delete' };
    var url = o.url == undefined ? "ashx/edit.ashx" : o.url;
    for (var attr in o.params) {
        action[attr] = o.params[attr];
    }
    layer.confirm('您确定要删除此条记录吗?', function (r) {
        if (r) {
            $.get(url + "?" + Math.random(),
             action,
                function (data, textStatus) {
                 if (data.flag) {
                     layer.msg('操作成功!');
                     try {
                         if (typeof (item_select) == "function") {
                             item_select();
                         }
                     } catch (e) {
                         layer.msg(e.message);
                     }
                     layer.close(r);
                 }
                 else {
                     layer.msg('非常抱歉，操作失败，请稍后重试');
                 }
                 if (typeof (o.callback) == "function") {
                     o.callback(data.flag);
                 }
             }
        )
        }
    });
}
//获取下拉
function get_selectall(type,selectid) {
    $.ajax({
        url: "../../ashx/get_select.ashx?type=" + type + "",    //后台webservice里的方法名称  
        type: "post",
        dataType: "json",
        contentType: "application/json",
        traditional: true,
        success: function (data) {
            for (var i in data) {
                var jsonObj = data;
                var optionstring = "";
                for (var j = 0; j < jsonObj.item.length; j++) {
                    optionstring += "<option value=\"" + jsonObj.item[j].ID + "\" >" + jsonObj.item[j].VALUE + "</option>";
                }
                $("#"+selectid+"").html("<option value='请选择'>请选择</option> " + optionstring);
            }
        },
        error: function (msg) {
            alert("出错了！");
        }
    });
}
//获取下拉
function get_selectdg(type) {
    $.ajax({
        url: "../../ashx/get_select.ashx?type=" + type+"&lb=qb",    //后台webservice里的方法名称  
        type: "post",
        dataType: "json",
        contentType: "application/json",
        traditional: true,
        success: function (data) {
            for (var i in data) {
                var jsonObj = data;
                var optionstring = "";
                for (var j = 0; j < jsonObj.item.length; j++) {
                    optionstring += "<option value=\"" + jsonObj.item[j].ID + "\" >" + jsonObj.item[j].VALUE + "</option>";
                }
                $("#get_select").html("<option value='请选择'>请选择</option> " + optionstring);
            }
        },
        error: function (msg) {
            alert("出错了！");
        }
    });
}
//动态获取下拉
function get_select(type, id,lb) {
    $.ajax({
        url: "../ashx/get_select.ashx?type=" + type+"&lb="+lb,    //后台webservice里的方法名称  
        type: "post",
        dataType: "json",
        contentType: "application/json",
        traditional: true,
        success: function (data) {
            for (var i in data) {
                var jsonObj = data;
                var optionstring = "";
                for (var j = 0; j < jsonObj.item.length; j++) {
                    optionstring += "<option value=\"" + jsonObj.item[j].ID + "\" >" + jsonObj.item[j].VALUE + "</option>";
                }
                $("#get_select"+id+"").html("<option value='请选择'>请选择</option> " + optionstring);
            }
        },
        error: function (msg) {
            alert("出错了！");
        }
    });
}
//动态获取下拉2
function get_select2(type, id,getselectvalue,lb) {
    $.ajax({
        url: "../ashx/get_select.ashx?type=" + type+"&lb="+lb,    //后台webservice里的方法名称  
        type: "post",
        dataType: "json",
        contentType: "application/json",
        traditional: true,
        success: function (data) {
            for (var i in data) {
                var jsonObj = data;
                var optionstring = "";
                for (var j = 0; j < jsonObj.item.length; j++) {
                    optionstring += "<option value=\"" + jsonObj.item[j].ID + "\" >" + jsonObj.item[j].VALUE + "</option>";
                }
                $("#get_select" + id + "").html("<option value='请选择'>请选择</option> " + optionstring);
                $("#get_select" + id + " option[value='" + getselectvalue + "']").attr("selected", true);
            }
        },
        error: function (msg) {
            alert("出错了！");
        }
    });
}
//标记为典型缺陷
function operate_badge(o) {
    var action = { Action: "get", act: 'badge' };
    var url = o.url == undefined ? "ashx/edit.ashx" : o.url;
    for (var attr in o.params) {
        action[attr] = o.params[attr];
    }
    bootbox.confirm('您确定要标记为典型缺陷吗?', function (r) {
        if (r) {
            $.get(url + "?" + Math.random(),
             action,
             function (data, textStatus) {
                 if (data.flag) {
                     messageSuccess('提示', '操作成功!');
                     try {
                         if (typeof (item_select) == "function") {
                             item_select();
                         }
                     } catch (e) {
                         messageInfo('提示', e.message);
                     }
                 }
                 else {
                     messageError('错误', '非常抱歉，操作失败，请稍后重试');
                 }
                 if (typeof (o.callback) == "function") {
                     o.callback(data.flag);
                 }
             }
        )
        }
    });
}
//2、复制行数据(表名，需要复制的id列表)
//jQuery.fn.extend({
//    item_copy: function (tablename, ids) {
//        bootbox.confirm('您确定要复制此条记录吗?', function (r) {
//            if (r) {
//                $.get("ashx/operate.ashx?" + Math.random(),
//                    { Action: "get", state: 'copy', tablename: tablename, ids: ids },
//                        function (data, textStatus) {
//                            var getdata = eval('(' + data + ')');
//                            try {
//                                selectid = getdata.data;
//                                if (typeof (item_select) == "function") {
//                                    item_select();
//                                }
//                                if (getdata.success) {
//                                    top.messageSuccess("提示", "操作成功");
//                                } else { top.messageError('错误', '非常抱歉，操作失败，请稍后重试'); }
//                            }
//                            catch (e) {
//                                top.messageError('错误', e.message);
//                            }
//                        });
//            }
//        });
//    }
//}
//);

////3、复制多表行数据(表名，需要复制的id列表)
//jQuery.fn.extend({
//    item_Copy_MoreTable: function (tablename, ids) {
//        bootbox.confirm('您确定要复制选中的记录吗?', function (r) {
//            if (r) {
//                $.get("ashx/operate.ashx?" + Math.random(),
//                    { Action: "get", state: 'Copy_MoreTable', tablename: tablename, ids: ids },
//                        function (data, textStatus) {
//                            var getdata = eval('(' + data + ')');
//                            try {
//                                selectid = getdata.data;
//                                if (typeof (item_select) == "function") {
//                                    item_select();
//                                }
//                                if (getdata.success) {
//                                    top.messageSuccess("提示", "操作成功");
//                                } else { top.messageError('错误', '非常抱歉，操作失败，请稍后重试'); }
//                            }
//                            catch (e) {
//                                top.messageError('错误', e.message);
//                            }
//                        });
//            }
//        });
//    }
//}
//);
//*******************************权限类*******************************
//判断是否维管段用户，如果是，则禁用掉相关操作按钮
function checkuseractions(btns) {
    var ischeck = true;
    if (userinfo.length > 0 && userinfo[0].ID != "" && userinfo[0].ID != null) {
        if (userinfo[0].ORGANIZATIONGNAME2WJGIDS != "") {
            ischeck = false;
        }
    }
    if (!ischeck) {
        for (var i = 0; i < btns.length; i++) {
            $('#' + btns[i]).hide();
        }
    }
}
///设置cookie
function setCookie(NameOfCookie, value, expiredays) {
    //@参数:三个变量用来设置新的cookie:
    //cookie的名称,存储的Cookie值,
    // 以及Cookie过期的时间.
    // 这几行是把天数转换为合法的日期
    var ExpireDate = new Date();
    //ExpireDate.setTime(ExpireDate.getTime() + (expiredays));
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
    // 下面这行是用来存储cookie的,只需简单的为"document.cookie"赋值即可.
    // 注意日期通过toGMTstring()函数被转换成了GMT时间。
    document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}
///获取cookie值
function getCookie(NameOfCookie) {
    // 首先我们检查下cookie是否存在.
    // 如果不存在则document.cookie的长度为0
    if (document.cookie.length > 0) {
        // 接着我们检查下cookie的名字是否存在于document.cookie
        // 因为不止一个cookie值存储,所以即使document.cookie的长度不为0也不能保证我们想要的名字的cookie存在
        //所以我们需要这一步看看是否有我们想要的cookie
        //如果begin的变量值得到的是-1那么说明不存在
        begin = document.cookie.indexOf(NameOfCookie + "=");
        if (begin != -1) {
            // 说明存在我们的cookie.
            begin += NameOfCookie.length + 1;//cookie值的初始位置
            end = document.cookie.indexOf(";", begin);//结束位置
            if (end == -1) end = document.cookie.length;//没有;则end为字符串结束位置
            return unescape(document.cookie.substring(begin, end));
        }
    }
    return null;
    // cookie不存在返回null
}
//取得cookie    
function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');    //把cookie分割成组    
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];                      //取得字符串    
        while (c.charAt(0) == ' ') {          //判断一下字符串有没有前导空格    
            c = c.substring(1, c.length);      //有的话，从第二位开始取    
        }
        if (c.indexOf(nameEQ) == 0) {       //如果含有我们要的name    
            return unescape(c.substring(nameEQ.length, c.length));    //解码并截取我们要值    
        }
    }
    return false;
}
///删除cookie
function delCookie(NameOfCookie) {
    // 该函数检查下cookie是否设置，如果设置了则将过期时间调到过去的时间;
    //剩下就交给操作系统适当时间清理cookie啦
    if (getCookie(NameOfCookie)) {
        document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
function deleteCookie(name) {
    var date = new Date();
    date.setTime(date.getTime() - 10000);
    document.cookie = name + "=v; expires=" + date.toGMTString();
}
function clearCookie(name) {
    setCookie(name, "", -1);
}
//清除所有cookie
function clearCookie() {
    var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
    if (keys) {
        for (var i = keys.length; i--;)
            document.cookie = keys[i] + '=0;expires=' + new Date(0).toUTCString()
    }
}